Programmable logic controller method, system and apparatus

ABSTRACT

A programmable logic controller with enhanced and extended the capabilities. A digital input filter implement filters with considerable less logic by simulating the action of a capacitor being driven by a constant current source whose output voltage is sensed by a comparator with a large amount of hysterisis. A pulse catch circuit captures the input pulse even though the update occurs between scan cycles. A pulse output controller includes a hardware pipeline mechanism to allow for smooth, hardware-controlled transitions from wave-form to wave-form. A free port link allows the user to control the port either manually or by operation of a user program. In order to provide higher performance for communication using PPI protocol, the PLC includes a built-in protocol. An n-bit modem protocol ensures data integrity without use of a parity type data integrity system. A hide instruction protects proprietary software by encrypting the sensitive code and decrypting the code during compilation and, thereafter, re-encrypting the code. A system function call allows the user to create and/or download new PLC functions and implement them as PLC operating system functions. An STL status function debugs programs during run-time and while the program is executing. A micro PLC arrangement provides compact size and efficiency.

PRIORITY

This is a divisional of application Ser. No. 09/538,817, filed Mar. 30,2000.

The present invention claims priority to a provisional application, U.S.Ser. No. 60/126,958, filed Mar. 30, 1999.

BACKGROUND

1. Field of the Invention

The present invention relates to a programmable logic controller (PLC).

2. Related Information

Programmable logic controllers (PLC's) are a relatively recentdevelopment in process control technology. As a part of process control,a PLC is used to monitor input signals from a variety of input points(input sensors) which report events and conditions occurring in acontrolled process. For example, a PLC can monitor such input conditionsas motor speed, temperature, pressure, volumetric flow and the like. Acontrol program is stored in a memory within the PLC to instruct the PLCwhat actions to take upon encountering particular input signals orconditions. In response to these input signals provided by inputsensors, the PLC derives and generates output signals which aretransmitted via PLC output points to various output devices, such asactuators and relays, to control the process. For example, the PLCissues output signals to speed up or slow down a conveyer, rotate thearm of a robot, open or close a relay, raise or lower temperature aswell as many other possible control functions too numerous to list.

The input and output points referred to above are typically associatedwith input modules and output modules, respectively. Input modules andoutput modules are collectively referred to as I/O modules herein. Thoseskilled in the art alternatively refer to such I/O modules as I/O cardsor I/O boards. These I/O modules are typically pluggable into respectiveslots located on a backplane board in the PLC. The slots are coupledtogether by a main bus which couples any I/O modules plugged into theslots to a central processing unit (CPU). The CPU itself can be locatedon a card which is pluggable into a dedicated slot on the backplane ofthe PLC.

FIG. 36 shows one typical conventional programmable logic controllersystem as system 3610. System 10 includes a host programmable logiccontroller 3615 coupled by a field bus 3620 to a bus interface unit3625. Bus interface unit 3625 couples and interfaces field bus 3620 to alocal bus 3630 which includes a plurality of I/O terminal blocks 3635.I/O terminal blocks 3635 are coupled to respective I/O modules 3640 asshown in FIG. 1.

In system 3610, computational processing is performed by the hostprogrammable logic controller 3615. In other words conditions are sensedat I/O modules 3640 and input data is derived therefrom. The input datais transferred through bus interface unit 3625 and field bus 3620 tohost programmable logic controller 3615. Host programmable logiccontroller 3615 acts on the input data according to a control programstored in host PLC 3615. Host programmable logic controller 3615processes the input data and produces output data in response thereto.The output data is transferred through field bus 3620, bus interfaceunit 3625, local bus 3630 to one or more I/O modules 3640. In responseto the output data, the I/O module receiving the output data controls anoutput device coupled to the I/O module. I/O termination blocks areprovided for coupling the I/O modules 3640 to the bus interface unit3625.

The PLC may be arranged in a master/slave network as shown in FIG. 37 a.In the figure, the master/slave control system includes a master PLC(M)and a plurality of remote slave units RSUs(R1–Rn). As shown therein, themaster PLC(M) including a master PLC, a data link, and an I/O module,controls its own I/O connection points using a program and acommunication parameter which are set by a user, and also controls therespective I/O connection points for the remote slave units R1–Rn. Eachof the plurality of RSUs(R1–Rn) has at least one I/O module, and carriesout a data communication with the master PLC(M) through a communicationcable, and accordingly controls its own I/O module. The RSUs may be PLCsacting as slaves.

With reference to FIG. 37 b, the PLC and each of the RSUs include: aMODEM 3710 for carrying out a communication between the master PLC(M)and the RSUs via a communication cable; a receive/transmit module 3711for exchanging data with the master PLC(M) according to a predeterminedprotocol; a receive/transmit buffer 3712 for temporarily storing thereinthe data for the exchange; an output data storage unit 3713 for storingtherein the data which are to be transmitted from the master PLC(M) toan input/output module 3716; an input data storage unit 3714 for storingtherein the data which are to be transmitted from the input/outputmodule 3716 to the master PLC(M); and an input/output control module3715 for controlling a data transmission between the data storage units3713, 3714 and the input/output module 3716.

In operation, the data link in the master PLC(M) is a data linkingdevice attached to the master PLC(M), which operates as a master unit inthe related network, and which obtains an initiative of the datacommunication. The data link is able to set a maximum number N of RSUs.The RSU sets each number of its own and the master PLC(M), and receivesa communication directly from the master PLC(M) for thereby carrying outa data transmission. The data link in the master PLC(M) sequentiallyselects the RSUs(R1–Rn) and carries out a data receiving/transmittingoperation. For example, when the data outputted from the master PLC(M)is applied through the communication cable and the MODEM 3710 to theRSU(R1), the applied data passes through the receive/transmit buffer3712 and the receive/transmit module 3711, and is stored in the outputdata storage unit 3713. The data stored in the output data storage unit3713 is outputted to the input/output module 3716 in accordance with thecontrol of the input/output control module 3715. The external controltarget data read from the input/output module 3716 of the remote slaveunit R1 is stored in the input data storage unit 3714 in accordance withthe control of the input/output control module 3715. The data stored inthe input data storage unit 3714 is transmitted through thereceive/transmit buffer 3712 and the receive/transmit module 3711 to themaster PLC(M).

The present invention provides new features that enhance and extend thecapability of the conventional PLC.

OBJECTS AND SUMMARY OF THE INVENTION

It is an object of the present invention to enhance and extend thecapability of the PLC.

It is another object of the invention to provide a digital input filterto enhance and extend the input capability of the PLC.

It is still another object of the invention to provide a pulse catchcircuit to enhance and extend the pulse catching capability of the PLC.

It is yet another object of the invention to provide a pulse outputcontroller to enhance and extend the output capability of the PLC.

It is a further an object of the invention to provide a free port linkto enhance and extend the portability of the PLC.

It is still a further object of the invention to provide a protocol formodem communication to enhance and extend the connectivity of the PLC.

It is yet further an object of the invention to provide a hideinstruction to enhance and extend the integration of the PLC withexternal programming applications.

It is still an additional object of the invention to provide a systemfunction call to enhance and extend the function call capability of thePLC.

It is an additional object of the invention to provide an STL status toenhance and extend the status acquisition capability of the PLC.

It is yet and additional object of the invention to provide a micro PLCwith an enhanced and extended capability.

In accordance with the foregoing objectives, the present inventionprovides a programmable logic controller with enhances and extended thecapabilities.

In one aspect of the invention, a digital input filter is provided. Thedigital input filter simulates the action of a capacitor being driven bya constant current source whose output voltage is sensed by a comparatorwith a large amount of hysterisis. The digital filter implements inputfilters with considerably less logic.

In another aspect of the invention, a pulse catch circuit is provided.The pulse catch circuit captures the input pulse even though the updateoccurs between scan cycles.

In yet another aspect of the invention, a pulse output controller isprovided. The pulse output controller smoothly transitions from one PTOor PWM wave-form to another. The pulse output controller includes ahardware pipeline mechanism to allow for smooth, hardware-controlledtransitions from wave-form to wave-form.

In a still another aspect of the invention, a free port link isprovided. The free port link allows the user to control the port eithermanually or by operation of a user program. In order to provide higherperformance for communication using PPI protocol, a built-in protocolselection option is provided.

In still another aspect of the invention, a protocol for modemcommunication is provided. In a particular arrangement, the modemprotocol supports communications over standard 10-bit, full duplexmodems. The protocol uses a novel technique to ensure data integritywithout use of a parity type data integrity system.

In a further aspect of the invention, a hide instruction is provided.The hide instruction provides for the protection of proprietary softwareby encrypting the sensitive code and decrypting the code duringcompilation and, thereafter, re-encrypting the code.

A still further aspect of the invention provides a system function call.The system function call allows the user to create and/or download newPLC functions and implement them as PLC operating system functions.

A yet further aspect of the invention is to provide an STL statusfunction. The STL status function allows the user to debug programsduring run-time and while the program is executing.

A quite further aspect of the invention is to provide the PLC in a microPLC arrangement.

These and other objects of the invention will be readily understood fromthe following description of the figures.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a perspective view of the PLC of the present invention;

FIG. 2 is a block diagram of the PLC;

FIG. 3 is a schematic diagram of the PLC;

FIG. 4 is a block diagram of the ASIC;

FIG. 5 is a block diagram of the input block;

FIG. 6 a is a block diagram of the input filter circuit;

FIG. 6 b is a truth table of the input filter circuit;

FIGS. 6 c and d are block diagrams of the input filter circuit;

FIG. 7 is a table of delay times;

FIG. 8 is a timing diagram of the scan cycle;

FIG. 9 is a block diagram of the pulse catch circuit;

FIG. 10 is a timing diagram of the scan cycle;

FIG. 11 is a timing diagram of the scan cycle;

FIG. 12 a is a truth table for the pulse catch circuit;

FIG. 12 b is a table for the pulse catch circuit enable register;

FIG. 12 c is a table for the pulse catch circuit reserved registers;

FIG. 12 d is a table for the pulse catch circuit input point statusregister;

FIG. 12 e is a block diagram for the pulse catch circuit;

FIG. 12 f is a block diagram for the pulse catch circuit;

FIG. 13 is a block diagram of the output block;

FIG. 14 a is a block diagram of the pulse output block;

FIG. 14 b is a table of registers of the pulse output block;

FIG. 15 is a state diagram of the pulse output block;

FIG. 16 is a software code listing;

FIG. 17 is a state diagram of the pulse output block;

FIG. 18 is a software code listing;

FIG. 19 is a table for high speed operations;

FIG. 20 is a block diagram of the I/O expansion slot.

FIG. 21 is a table for the I/O expansion slot;

FIG. 22 is a block diagram of the I/O expansion module;

FIG. 23 is a table of components;

FIG. 24 is a table of levels;

FIG. 25 is a timing diagram of the read cycle;

FIG. 26 is a timing diagram of the write cycle;

FIG. 27 is a table of parity bits;

FIG. 28 is a table of CPU types;

FIG. 29 is a table of interrupts;

FIG. 30 a is a flow chart of the free port;

FIGS. 30 b, c and d are tables of SM bit definitions;

FIG. 30 e is a table of port definitions;

FIG. 31 is a flow chart of the modem protocol;

FIG. 32 a is a table of control functions;

FIG. 32 b is a flow chart of the hide instruction;

FIG. 33 a is a table of control functions;

FIG. 33 b is a flow chart of the system function call;

FIG. 34 a is a table of STL instructions;

FIG. 34 b is a system diagram of the STL function;

FIG. 34 c is a flow chart of the STL function;

FIG. 34 d is a table of boolean expressions;

FIG. 35 a is a table of PLC parameters;

FIG. 35 b is a perspective view of the PLC and I/O expansion module;

FIG. 36 is a block diagram of a PLC;

FIG. 37 a is a block diagram of a master/slave system;

FIG. 37 b is a block diagram of communications in the master/slave;

FIG. 38 is a schematic diagram of a high speed DC output; and

FIG. 39 is a schematic diagram of a high speed DC output of the presentinvention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

General Description of the Programmable Logic Controller (PLC)

The exemplary Programmable Logic Controller (PLC) 100 of the presentinvention is shown in FIG. 1.

The figure illustrates the input/output (I/O) capabilities of the PLC100. The user controls the PLC 100 by operation of the run/stop switchpotentiometer and expansion I/O connector 104. Status light emittingdiodes (LED's) 106 indicate the status of the PLC 100. A cartridge port108 is provided for receiving a cartridge for expanding the function ofthe PLC 100 including, for example, increasing the memory. I/O LED's 110are provided for indicating the status of the input/output pins of thePLC 100. A communications port 112 couples the PLC 100 to externalcomponents including, for example, other PLCs. The communications portmay be used to connect the PLC 100 to other PLCs in a master slaverelationship. The communications port 112 may also be used to connectto, for example, to a computer (such as a network computer or a personalcomputer). The PLC 100 may also connect to the internet through thecommunications port 112 via a modem or equivalent communicationsprotocol device. User wiring connector 114 allows the user to connectexternal the PLC 100 to devices, such as motors and other peripheraldevices.

In the figure, the PLC 100 is shown adjacent an expansion I/O thatexpands the input/output capabilities of the PLC 100. The expansionmodule, as well as the PLC 100, includes DIN rail mounting latch(es) 116and a panel mounting location 118 for affixing the PLC 100 and theexpansion I/O 102 to a suitable mounting fixture.

It will be appreciated that the PLC 100 of the present invention mayinclude multiple arrangements and configurations of PLCs, severalexpansion I/O modules, and accessories that include memory cartridges,clock cartridges, battery cartridges cables or I/O simulator switchassemblies. This invention will address a fraction of the possibleconfigurations relevant to the particulars of the various aspectsdescribed herein and the practitioner will instantly recognize theseconfigurations with an understanding of the herein-described invention.

The PLC of the present invention is classified as a Micro PLC because ofits small physical size. While the PLC is physically small in size, itincludes many features that make it as powerful as (if not more powerfulthan) physically larger PLCs. FIG. 1 shows a drawing of the PLC and anI/O module with possible dimensions. The design of the PLC 100 isdescribed with reference to FIGS. 39 a and b.

FIG. 2 shows a block diagram 200 of the PLC of the present invention.The block diagram shown is for a PLC with an integral AC power supply202 for providing power. A central processing unit 210 is the core ofthe PLC 200 (100) and includes an ASIC, ROM and RAM. A digital inputinterface 212 is provided for inputing signals from the user wiring 114(FIG. 1). A digital output interface 204 couples the PLC 200 to the userwiring 114 (FIG. 1). A communications interface 206 couples the PLC 100to external devices via, for example, an RS-485 or token buscommunication. An expansion I/O interface 208 connects the PLC 200 toexpansion I/O interface(s) via, for example, a high speed, multiplexedbus.

In operation, the AC power supply 202 may provide an isolation boundarybetween the AC line and outputs, such as the 24VDC and 5VDC outputs. ThePLC may be offered with a 24VDC power supply as well. The 24VDC powersupply models would not provide isolation from 24VDC to 5VDC. Thedigital input interface 212 optically isolates the user wiring from theCentral Processing Unit (CPU) 210 which includes all the logic levelsignals. The digital output interface provides a similar isolationboundary between the user wiring and the CPU. This isolation boundary isprovided in the form of optical isolation or through relays where therelay coil is isolated from the relay contact. No isolation is shown inthe figure between the CPU and the communication interface or theexpansion I/O interface, but may be provided. All expansion I/O modulesprovide an optical isolation boundary between user wiring and the 5VDClogic signals. The CPU 210 is comprised of the ASIC which includes themicroprocessor, RAM and ROM. The ROM contains the operating system forthe PLC 200 and may be either EPROM or FLASH EPROM depending upon thePLC model. The RAM is used for operating system data storage and scratchpad as well as for storing the user program that has been compiled intoexecutable code.

A block diagram of the Central Processing Unit (CPU) 300 H/W is shown inFIG. 3. The connections of the CPU shown are not described in detailherein. The particular connections of interest here are the inputcircuits on I/O board 302, the I/O expansion bus 304 and the outputcircuit on I/O board 306 connections. In any event, FIG. 3 illustratesthese details in sufficient schematic clarity that the practitioner willhave no problem understanding the details from a review of the figure.It shall be appreciated that FIG. 3 illustrates only one arrangement andthat those skilled in the art will readily understand how to implementother, equivalent, arrangements particularly in view of the instantspecification.

The CPU 300 and connections are arranged as an ASIC shown indiagrammatic form in FIG. 4. As shown, the ASIC includes amicroprocessor 406 (labeled “core”), address decode unit 402 and mappinglogic. Two UARTs (Universal Asynchronous Receiver Transmitter) 424, 426are provided that effect the electronic circuit that makes up the serialport. UARTs convert parallel bytes from the CPU into serial bits fortransmission, and vice versa. However, other communication arrangementsare possible. There are digital input conditioning circuits 418, highspeed counters 410, pulse train output circuitry 420, potentiometercircuitry 414, watchdog circuitry 430 and reset circuitry 428. A businterface 404 is provided. The expansion I/O unit is labeled 422. A testinterface is provided for testing the PLC 100. The power distributioncircuit is illustrated as circuit 432. The memory is shown as internalRAM 408. An interrupt control unit 412 handles interrupts for the CPU406.

The PLC 100 provides a means for users to create specific applicationcontrol programs that, when executed by the PLC, direct the operation ofmachines and/or processes used in the manufacturing of a wide variety ofproducts. In this way the PLCs are similar to all other PLCs and thepractitioner will immediately understand the more mundane aspects of theinvention with such basic understanding of PLCs. In spite of thesimilarity in use and function of the PLCs there are many uniquefeatures and functions that are blended into the PLC 100 of the presentinvention which expand and enhance its utility to the user as willherein be described.

Digital Input Point Unit

The digital input point unit 418 will be described. After each of thedigital input signals (I0.0 to I1.5) has been converted to a compatiblesignal, e.g., +5V signal, and isolated from the user wiring, it is fedinto the Digital Input Point Unit 418 of the ASIC. A block diagram forinput points IB0[2:0] which illustrates the functionality provided bythe Digital Input Point Unit 500 (418, FIG. 4) is shown in FIG. 5.

This unit 500 performs a number of functions on the digital input pointsconnected from the user's application to the CPU. This unit filters theinput points and provides access to the filtered state of these points.A pulse catch functionality is provided on each input point tooptionally allow the capture of short duration pulses. An edge interruptfunction is provided to generate interrupts on the occurrence of risingand falling edge transitions on certain input points. High-speedcounters are used to count events that occur too fast for the CPU scanrate.

As shown in FIG. 5, a digital input filter(s) 506 _(1-n) provides asoftware configurable filter. That is, the PLC sets the filterparameters that control the filtering function in accordance withsoftware executed by the PLC. In at least one arrangement, up to 8filter values are configurable by software, from 0.2 msec to 12.8 msec,for example. Filter implementation is possible with, for example, a4-bit up/down counter on each input point. A pulse catch circuit(s) 508_(1-n) allows for the capture of a rising or falling edge transition ofthe filtered input until software has a chance to read the value.Independent enable/disable of the pulse catch function is provided foreach input point. An edge interrupt circuit(s) 510 _(1-n), when thisfunction is enabled, generates an interrupt upon the occurrence of arising edge and/or falling edge transition on, for example, up to fourinput points. High-speed counter(s) 514 (516), in this case sixhigh-speed counters (HSC) are supported, each contain, for example, a32-bit up/down counter and a 32-bit compare register.

The 32-bit register captures the counter value so that it can be read bysoftware. Each counter and compare register are loadable by software.Four of the HSC's, for example, can handle two-phase clocking. The othertwo HSC's may support single-phase clocking only. Each HSC can generateinterrupts upon the occurrence on equality of the counter vs compareregister, upon a direction change condition, and upon the assertion ofthe HSC's external reset input.

Digital Input Filter Circuit

The implementation of the input filters in previous ASIC circuitryconsumes too many gates. In the ASIC of the present invention, there isa need to provide compatible functionality without consuming so manygates. The following is a description with reference to FIGS. 6 a to 6 dand 7 that implements input filters with considerably less logic in theinstant ASIC by employing the truth table of FIG. 6 b.

The ASIC provides digital input filtering for, for example, fourteendigital input points as shown in FIGS. 6 a and 6 b. In FIG. 6 a, thedigital input filter circuit 600 (506, FIG. 5) includes input 602, inputfilter circuit 604, selected delay time 606 and output 608. The filterdelay times set by the selected delay time 606 are software configurableto, for example, one of seven different values. The filter delay timesare selected through settable registers internal to the ASIC. Thefollowing table in FIG. 7 describes the possible relationship betweenthe value written to the register and the corresponding delay timeselected. Of course, other relationships are possible.

Each digital input filter simulates the action of a capacitor beingdriven by a constant current source whose output voltage is sensed by acomparator with a large amount of hysteresis. The digital equivalence ofthis analog circuit is implemented as a four bit, up/down counter whosecounting direction is controlled by the state of the input point. Thefrequency at which the counter is clocked is determined from theselection values written into registers internal to the ASIC bysoftware. The 1 MHz Master Clock is used as the time base for eachfilter so that its operation is independent of the system clockfrequency. The delay time is calculated from the following formula:digital filter delay time=12*(period of the up/down counter's selectedinput clock)

The truth table in FIG. 6 b defines the operation of the digitalequivalent circuit where the result produced by the filter is the outputvalue 608 (FIBy.x). One skilled in the art will immediately appreciatethat the details of the circuitry may be implemented from the table inFIG. 6 b using well-known boolean logic. The exemplary circuit is shownin FIG. 6 c.

For each group of, for example, four inputs a multiplexer 610 outputsone of eight clocks which is used to set the input filter delay time.The clock selected by the multiplexer 610 drives a four bit up/downcounter 612 (one for each of the inputs in each group of four inputs).The physical input controls the direction (up/down) of the four bitcounter. When the input is ON (logical ‘1’) the counter counts up. Whenthe input is OFF (logical ‘0’) the counter counts down. The count upsequence of the counter is:

0, 1, 2, . . . 13, 14, 15, 15, 15, . . . 15

The count down sequence of the counter is:

15, 14, 13, . . . 2, 1, 0, 0, 0, . . . 0

As indicated by the counting sequence, the counter will not roll overwhen counting up or when counting down.

The filter delay 614 is designed to mimic the operation of a constantcurrent source driving a capacitor whose voltage is sensed by acomparator with a large amount of hysteresis. In this case, in order todetect an input transition from off to on, the counter must reach acount of 12. Once this count is reached, the output will be turned onand it will remain on until the threshold for an input transition fromon to off is reached at a count of 3. The nand gate logic 620 shown inthe figure implements these thresholds.

The thresholds are semetric in that 12 up counts or 12 down counts arerequired from a steady state low or high input condition. The table inFIG. 6 d lists the delay times for 12 clocks at each of the frequenciessupplied to the multiplexer. Of course, other delay times are possible.Additional layers, each layer including a counter 616, nand gate logic622 and a delay 618 may be provided for each input that operate in acorresponding manner as the afore-described layer.

Pulse Catch Circuit

Following the digital input filter circuit is a pulse catch circuit(508, FIG. 5).

The purpose of this circuit is to capture either a change in the inputstate from high to low or from low to high and hold it until the PLCoperating system software has recognized the change in state. The PLCreads the state of the inputs in a cyclic fashion in both STOP and RUNmodes. (The main difference between STOP and RUN modes in the PLC isthat in STOP mode the user's program is not executed whereas in RUN modethe user's program is executed.) FIG. 8 shows the PLC scan cycle (thecycle is normally called the PLC scan cycle or simple scan.) As shown inFIG. 8, the PLC scan cycle in RUN mode reads the input once per cycle.The same scan cycle is followed in STOP mode, but the user program isnot executed in STOP mode.

Since inputs are only read once per cycle, it is possible for inputs tochange state without the PLC ever recognizing the change. Such statechanges that occur too fast for the PLC to recognize are referred to aspulses. In order to prevent the PLC from missing a short pulse on aninput, the user can enable an input interrupt which will suspend normalprogram execution while the PLC services the interrupt. This method isvery effective, but it requires additional support from the CPU and usesup considerable execution time to process the interrupt routine. Forthis reason only a small number of input interrupts are allowed.

The other method is to provide pulse catch circuits on each of theintegral inputs to the PLC. This method allows infrequent but shortduration pulses (either high going or low going) to be captured and helduntil the PLC recognizes the change at the appropriate point in the scancycle.

Pulse Catch Circuit Top-Level Block Diagram

Now in more detail, FIG. 9 illustrates the pulse catch circuit 900 (508,FIG. 5) wherein input 902 are coupled to pulse catch circuit 904, arecaptured according to the enable signal 906, and output 908. In thismanner, the pulse capture circuit is able to capture and hold digitalinput point pulses whose duration is greater than the selected filtertime but is less than the scan time. FIG. 10 illustrates the problemwhere the pulse is missed because the pulse occurred between the inputupdates.

The CPU software is designed to read the state of all input points onceper CPU scan and this operation is called the input update. As mentionedabove, a pulse can be missed if it occurs between the input updates ofconsecutive CPU scans (see the example in FIG. 10). The pulse catchcircuit 904 captures and holds this type of event. In one possiblearrangement, there are fourteen pulse catch circuits, one for each inputpoint.

When a pulse catch circuit is enabled, a change in state (low → high orhigh → low) of an input is captured. Further state changes of the inputare ignored until the captured value has been read by the softwareduring the next CPU scan. Once the captured value has been read, thecircuit is then able to detect new input state changes.

The operation of the pulse catch circuit can be described more preciselywith the truth table for a synchronous state machine shown in FIG. 12 a.The symbols used in this table are defined below:

-   PCE—Pulse catch circuit enable bit-   I—Input signal synchronized to the system clock by the input filter    circuit (FIBy.x)-   CV—The input value captured after state change of the input and    after an input update    (Synchronized to the System Clock)-   F—State change flag (synchronized to the system clock)-   RP—Read pulse (one for each input status byte) generated by a read    of the input status byte    (Synchronized to the System Clock in such a way that it is Active    for One Clock Cycle and goes    Inactive on the Clock Edge that Transferred the Status of the Input)-   PS—Present State-   NS—Next State

In operation, and with reference to FIG. 12 a, when the circuit detectsa change of state on the input, the new value of the input is capturedand a state change flag is set. While the state change flag is set, thestored input value is held and cannot be updated. Therefore, any inputchanges occurring while the state change flag is set are ignored. Afterthe stored value is read by software, the state change flag is reset,the current state of the input is captured, and the detection of inputstate changes is re-enabled. This sequence of actions is calledre-triggering the pulse catch circuit. The result is that the inputpulse is captured even though the update occurs between scan cycles asshown in FIG. 11. See, for example, CIB1.6 that shows that the pulsecatch circuit output 908 captures the input pulse 902 even though thepulse occurs between scans, i.e., scan n and scan n+1.

Two 8-bit registers, for example, are provided in this block forindividually enabling and disabling the pulse catch function on each ofthe sixteen input points. These enable registers are defined in thetable shown in FIG. 12 b. Input status registers are provided to givethe CPU software access to the conditioned input point states, CIB0[7:0]and CIB1[5:0], which are output from the pulse catch circuitry. Theseare shown in FIG. 12 c. The format of the input status registers isshown in FIG. 12 d.

The circuit elements of the pulse catch circuit, as will be appreciatedby those skilled in the art, will be readily recognizable from the truthtable shown in FIG. 12 a. It will further be appreciated that the pulsecatch circuit, therefore, may have a plurality of configurations thatfulfill the truth table.

The exemplary pulse catch circuit that operates in accordance with theforegoing description is shown in FIGS. 12 e and 12 f. A system clockpulse drives flip-flops 1202, 1208. The input signal is coupled to thefirst flip flop 1202, the Q output of which is coupled to the nand gatelogic 1206. Signals PCE, RP and F are delayed and coupled tocorresponding nand gates in the nand gate logic 1206, as shown. Inaddition, the output of the second flip flop 1208 is fed back to thenand gate logic 1206. The output of the nand gate logic is coupled tothe second flip flop 1208 and, upon being latched thereby, is clocked tothe output. The F signal is generated in FIG. 12 f, wherein the systemclock drives flip flops 1210 and 1216. The first flip flop latches theinput and the second flip flop latches the output of the nand gate logic1214. The nand gate logic 1214 is arranged as shown to implement theafore-described logic on the signals output from the first flip flop(O), the inverted version of Q, the captured version of the input signaland its delayed version (delayed by the delays 1212), the RP signaldelayed by delays 1212 and the PCE signal.

The pulse catch circuits can be individually enabled and disabled. If apulse catch circuit is disabled, then the circuit input is passedthrough to the circuit output. If enabled, then the pulse catchfunctions described above are active.

Digital Output Point Unit

This digital output unit (420, FIG. 4) allows direct software control ofthe state of each output point. In addition, a pulse output capabilityallows pulse train output and pulse width modulated output on up to twoof the output points.

Now with reference to FIG. 13, the ASIC provides two output point stateregisters 1302, 1304 for software control of the state of ten digitaloutput points. In addition, two Pulse Output Blocks 1306, 1308 (PLSs)may be implemented to provide the capability of generating pulsedwave-forms at a frequency faster than software can accomplish.

Within the pulse output blocks 1306, 1308, the ASIC provides a choice oftwo output functions, e.g., PWM (pulse width modulated) or PTO (pulsetrain output). The PWM function provides for continuous pulse outputwith a programmable cycle time and duty cycle. Intended mainly forstepper motor applications, the PTO function provides for the output ofa specified number of approximately 50% duty cycle pulses. Of course,other applications will be appreciated by those skilled in the art. Thecycle time in the PTO function is also programmable and can either befixed or can be automatically adjusted to increase or decrease at auser-specified rate.

When PLS0 is operating (enabled), it has control of output point XQB0.0via MUX 1310. Otherwise, XQB0.0 is controlled by the value whichsoftware writes to the output point state register of the ASIC.Likewise, PLS1 controls the state of XQB0.1 if enabled, via MUX 1312,and the output point state register of the ASIC controls the state ofXQB0.1 if PLS1 is not enabled.

Pulse Output Blocks

The ASIC shown supports two pulse output (PLS) blocks. Of course, anynumber of PLSs are configurable. These blocks allow the CPU to producewaveforms at frequencies faster than the CPU software is capable ofmanually generating. The output from Pulse Output Block 0 (PLS0) is oneof the sources of output point XQB0.0 and the output from Pulse OutputBlock 1 (PLS1) is one of the sources of output point XQB0.1.

The ASIC for the PLCs provided both the Pulse Train Output (PTO) and thePulse Width Modulated (PWM) functions. PTO is an operational mode inwhich the period (cycle time) of the wave-form and the number of cycles(pulse count) is specified by software. The duty cycle of the wave-formis approximately 50%. PWM is an operational mode in which the period(cycle time) and duty cycle (pulse width) are specified by software andthe wave-form is output continuously.

It was discovered that there was a fundamental problem with theimplementation of these functions in that there was no way to smoothlytransition from one PTO or PWM wave-form to another. Each transitionrequired that the pulse output block be stopped by the software and thenrestarted which introduced a discontinuity in the resultant outputwave-form.

Because of the problem with transitions from one wave-form to another asdescribed above, the ASIC of the present invention provides the pulseoutput block with a hardware pipeline mechanism to allow for smooth,hardware-controlled transitions from wave-form to wave-form. Also, toallow for better operation with stepper motors, the ability toautomatically ramp the value of the cycle time at a specified rate wasadded to the ASIC.

PLS Block Diagram and Operational Overview

The block diagram in FIG. 14 a shows the organization and components ofeach pulse output block 1400.

PLS Time Base Generation—The time base (e.g., 1 ms or 1 μsec) isprovided by a multiplexer 1402 that selects either, for example, the 1MHz Master Time Base clock or a 1 KHz clock derived from the Master TimeBase clock.

Wave-form Period Control—The output of the time base multiplexer drivesa 16-bit up counter, called the cycle time counter 1420. This counter isincremented on the rising edge of the time base clock. The output ofthis counter is compared by comparator 1430 with the value stored in a16-bit cycle time preset register 1422 to control the period of theoutput wave-form. When the value of the cycle time counter reaches thevalue of the cycle time preset register, then the current cycle iscomplete and the CycleDone event is generated.

The values stored in the cycle time counter 1420 and cycle time presetregister 1422 are unsigned values. The valid range of the cycle timecounter 1420 is, for example, 0 to 65535. The valid range of the cycletime preset register is 2 to 65535. The comparison to determineCycleDone is an unsigned comparison.

A delta cycle time register 1406 exists for use in PTO mode to hold asigned, twos-complement 16-bit value that is added to the value storedin the cycle time preset register 1422 at each CycleDone event. If thesum exceeds 65535 or is less than 2, then the AdderError event isgenerated. For example,

preset = 65530  (FFFAH preset = 65530  (FFFAH unsigned) unsigned) delta= −20  (FFECH signed) delta = 20  (0014H signed) sum = 65530 + (−20) =65510  OK sum = 65530 + (20) = 65550  Adder Error !!! preset = 100 (0064H unsigned) preset = 100  (0064H unsigned) delta = −20  (FFECHsigned) delta = −120  (FF88H signed) sum = 100 + (−20) = 80 OK sum =100 + (−120) = −20 Adder Error !!!

In PWM mode, the delta cycle time register is held at a value of 0.

Software may load the cycle time preset register 1422 and the deltacycle time register 1406 only when the PLS block is disabled. The validrange of this register in PTO mode is, for example, −32768 to +32767.

Wave-form Duty Cycle Control—The output of the cycle time counter 1420is also used in the control of the wave-form's duty cycle. There is anunsigned comparison performed between this counter value and a pulsewidth preset value whose source is determined by the PLS operating mode.The state of the PLS block output signal PLS×OUT is determined by thiscomparison. While the counter value is less than the pulse width presetvalue, the PLS×OUT signal is high. When the counter value reaches orexceeds the preset, then the PLS×OUT signal is driven low. The pulsewidth preset value is obtained from the lower 16-bits of the pulsecount/width preset register 1408, if in PWM mode, or is one-half thevalue stored in the cycle time preset register 1422, if in PTO mode.

If the pulse width preset value is 0, then PLS×OUT will be low for theentire cycle. If the pulse width preset value is equal or greater thanthe cycle time preset, then PLS×OUT will be high for the entire cycle.

The pulse count/width preset register 1408 is loaded by software butonly the lower 16-bits are significant when operating in PWM mode.Therefore, software should only write the least significant word of theregister in PWM mode. The valid range of this register in this mode is 0to 65535. This register may be loaded by software only when the PLSblock is disabled.

Cycle Quantity Control (PTO mode only)—A 32-bit up counter, called thepulse counter 1428, is driven on each CycleDone event to count thenumber of cycles generated on the PLS×OUT signal. The value stored inthis counter is compared by comparator 1434 to the value in the 32-bitpulse count preset register 1416 to determine completion of the currentPTO operation. When the pulse counter 1428 value reaches the pulse countpreset value, the PTOComplete event is generated. In PWM mode, thiscounter is not used.

In PTO mode, the full 32-bits of the pulse count/width preset register1416 is significant and is loaded by software. The valid range of thisregister in this mode is 1 to (2³²−1). This register may be loaded bysoftware only when the PLS block is disabled.

Operational Control—A control register contains bits to allow thesoftware to enable or disable the operation of the PLS block. Oncesoftware enables the PLS block, the switch-over of the output point fromQBxPS control to PLS block control as well as the operation of internalcounters and comparisons is synchronized with the next rising edge ofthe time base clock. This is done to ensure that the initial cycle ofthe output wave-form is of proper duration and pulse width. Thisregister is held at its reset state in the case of watch dog time outfault condition or due to direct software control of the output disablefunction.

A setup register contains bits to allow the software to configure theoperation of the PLS block. Included are a PLS time base select and anoperating mode select. An interrupt enable register gives the softwarethe ability to individually enable and disable interrupt generation forthe PTOComplete and AdderError interrupt events. A status register isprovided to allow the software to obtain information about the currentoperational state of the PLS block. This information includes theenabled state and the state of the pipeline loaded flag (describedbelow).

An interrupt status register provides information on the interruptsource or sources generating the interrupt condition. The INTxPLS signaloriginates from the PLS block and is used by the Interrupt Control Unit.This signal becomes active when one or both of the PLSinterrupt-generating events has occurred (subject to the state of theinterrupt enable bits in the interrupt enable register). Reading theinterrupt status register will clear all active interrupt indications inthe PLS block and release the INTxPLS signal. Also, disabling aninterrupt generation source in the interrupt enable register will cleara pending interrupt from that source. If no other interrupts are thenpending in the PLS block, the INTxPLS signal will be released.

Hardware Pipeline Mechanism—The pipeline mechanism is provided so thatmodifications to the wave-form characteristics can be applied with noresultant wave-form distortion. The following pipeline registers areprovided to hold the new values for cycle time, pulse width, etc:

-   -   Cycle time pipeline register is used to store the new cycle time        value.    -   Delta cycle time pipeline register is used to store the new        delta cycle time value.    -   Pulse count/width pipeline register, is used to store the new        pulse count or pulse width value (if in PTO mode, this register        stores a new pulse count and the full 32-bits of the register        are used. If in PWM mode, this register stores a new pulse width        value and only the lower 16-bits of the register are used).

A pipeline loaded flag is implemented as part of the interface betweenthe PLS block and software when using the hardware pipeline mechanism.The pipeline loaded flag is set whenever the software writes a value tothe least significant byte of the pulse count/width pipeline register.Therefore, to use the hardware pipeline mechanism, the software mustalways write a value into the pulse count/width pipeline register and itmust be the last pipeline register to be written.

All pipeline registers must be loaded by software since the contents ofall pipeline registers will be transferred to the operating registers.In PWM mode, software does not need to write to the delta cycle timepipeline register because the delta cycle time register is held at 0while the PLS block is in PWM mode. Any contents of that pipelineregister are effectively discarded.

Once the pipeline registers are written and the pipeline loaded flag isset, the contents of the pipeline registers will be transferred to theoperating registers under the following conditions:

-   -   If the PLS block is enabled, the transfer will be made upon the        occurrence of the PTOComplete event, if in PTO mode, or the        CycleDone event, if in PWM mode.    -   If the PLS block is disabled, the transfer will be made        immediately when the PLS block is enabled by software

After the transfer to the operating registers is made, the pipelineloaded flag will then be automatically cleared.

Once the pipeline loaded flag is set in an enabled PLS block, thesoftware is prevented from writing into any of the pipeline registersuntil their contents have been transferred into the operating registers(signified by the clearing of the pipeline loaded flag by the ASIC). Ifthe PLS block is disabled, then the pipeline registers may be written bysoftware with no restrictions and each time that the least significantbyte of the pulse count/width pipeline register is written, the pipelineloaded flag will be set.

Auto-disable Mechanism—An enabled PLS block in PTO mode can beautomatically disabled under the following conditions:

-   -   The PTOComplete event occurs and there is no new wave-form setup        stored in the pipeline registers (the pipeline loaded flag is        0).    -   The AdderError event occurs.

When the PLS block is automatically disabled, the master enable bit inthe control register is cleared by the ASIC. The pipeline loaded flag isnot affected.

Manual Disable—Whenever the master enable bit in the control register iscleared by software, the PLS block will immediately enter the PTODisabled State or the PWM Disabled State (described below), dependentupon the current operating mode of the block. A software disable willalso clear the pipeline loaded flag and any pending interrupts.

Valid Register Ranges—The table in FIG. 14 b shows the range of validvalues for each of the numeric registers in the PLS block.

PTO Operation

This mode is selected by enabling the PLS block. Software will controlthe cycle time, the delta cycle time, and the pulse count. The dutycycle is fixed at 50%. Therefore, the following functionality of the PLSblock is enabled for use in this mode:

-   -   The cycle time preset and cycle time pipeline registers.    -   The delta cycle time and delta cycle time pipeline registers.    -   The pulse count/width preset and pulse count/width pipeline        registers (configured to hold the 32-bit pulse count).    -   The 32-bit pulse counter.    -   The 16-bit cycle time counter.    -   The comparison to generate the CycleDone event.    -   The comparison to generate the PTOComplete event.    -   The comparison to control the state of PLS×OUT.    -   The pipeline loaded flag.    -   The PTOComplete and the AdderError interrupts.

Major state transitions of the PLS block in PTO mode are shown in thestate diagram 1500 of FIG. 15.

When the PLS block is in the PTO disabled state 1502:

-   -   The QB0.x output is controlled by Output Point State Register        instead of the PLS block.    -   The cycle time counter and the pulse counter are held at 0.    -   The PLS×STAT.EN status bit indicates disabled.

When the PLS block is in the PTO operating state 1504,

-   -   The QB0.x output is controlled by the PLS block (through the        PLS×OUT signal).    -   The PLS×STAT.EN status bit indicates enabled.    -   Normal PTO operation is enabled.

The cycle time counter is incremented on the rising edge of the PLS timebase and most of the functionality of the PLS block is driven, eitherdirectly or indirectly, from that counter. The segment in FIG. 16 ofpseudo-code outlines the ASIC actions in PTO mode occurring on a risingedge of the PLS time base (the order of the actions is important, soassume top-to-bottom evaluation of these statements). The skilledpractitioner will instantly appreciate the operation of the ASIC in PTOmode from the pseudo-code.

PWM Operation

This mode is selected by enabling the PLS block. Software will controlthe cycle time and the pulse width. Therefore, the followingfunctionality of the PLS block is enabled for use in this mode:

-   -   The cycle time preset and cycle time pipeline registers.    -   The pulse count/width preset and pipeline registers (configured        for a 16-bit pulse width).    -   The 16-bit cycle time counter.    -   The comparison to generate the CycleDone event.    -   The comparison to control the state of PLS×OUT.    -   The pipeline loaded flag.

The delta cycle time register and the delta cycle time pipeline registerare held at 0 and the pulse counter and interrupt generation for theblock are disabled. The INTxPLS signal should always be driven to theinactive state in this mode.

Major state transitions of the PLS block in PWM mode are shown in thestate diagram shown in FIG. 17.

When the PLS block is in the PWM disabled state 1702:

-   -   The QB0.x output is controlled by the Output Point State        Register instead of the PLS block.    -   The cycle time counter is held at 0.    -   The PLS×STAT.EN status bit indicates disabled.

When the PLS block is in the PWM operating state 1704,

-   -   The QB0.x output is controlled by the PLS block (through the        PLS×OUT signal).    -   The PLS×STAT.EN status bit indicates enabled.    -   Normal PWM operation is enabled.

The cycle time counter is incremented on the rising edge of the PLS timebase and most of the functionality of the PLS block is driven, eitherdirectly or indirectly, from that counter. The segment shown in FIG. 18of pseudo-code outlines the ASIC actions in PWM mode occurring on arising edge of the PLS time base (the order of the actions is important,so assume top-to-bottom evaluation of these statements). The skilledpractitioner will instantly appreciate the operation of the ASIC in PWMmode from the pseudo-code.

Pulse Train Output Profile Instruction (PTOP)

The pulse output function provided by the ASIC is primarily intended foruse in controlling stepper motors. The PLC provides a user instructionfor the generation of profiles for acceleration/deceleration and runningof stepper motors. This instruction is shown in FIG. 19.

Expansion I/O Unit

Overview of Expansion Bus Concept

Physically, the expansion subsystem consists of enclosed I/O moduleswhich are mounted independently, without a common back plane. A tenconductor ribbon cable which is part of each module is used to connectto the preceding module or the CPU. This cable carries the 5V power andlogic signals required for the modules operation. See FIG. 20. Thesignals in the I/O expansion bus are described in FIG. 21.

While all signals are physically daisy-chained through the modules, onlyEMA signals are logically broken and regenerated at each module. Allother signals form a single electrical bus that extends the length ofthe I/O module chain. The value of the EMA signals is incremented beforeit is passed to the next module. Each access to the expansion I/O busincludes a module address field for selection of the module to beaccessed. Only the module whose address matches the module address fieldof the message will respond to the access. This scheme allows arbitrarymixes of I/O module types to be concatenated without address switchesand without a fixed back plane. Logical expansion of up to 8 units ispossible with three EMA signal lines, however only 7 modules are allowedat present. Of course, other expansion units are possible.

FIG. 22 shows the logical structure 2200 and the signal flow of I/Omodules 2202 in the present invention. The details of the I/O expansionlogical structures are not herein described. The table in FIG. 23 givesthe values for each of the components used in the electrical interfaceof an expansion I/O module. The tables in FIG. 24 describe theelectrical characteristics of the I/O bus signals. Access to expansionI/O is controlled by the ASIC in the CPU and will be understood from thediagrams in FIGS. 25 and 26 which illustrate the read and write cyclesequences as seen on the expansion I/O bus.

The ASIC (Master State Machine and Transaction Timing)

The following describes the bus transaction sequence. EM bus timing isarranged to provide time for propagation delay and signal skew whereneeded. The master provides signals on falling edge clocks of EMC, to belatched by the slave on the next rising edge. One half EMC clock time isallowed to cover set up of the data to the slave, and allow for worstcase skew of EMC vs. EMD through the ASIC buffers, external cables, andpossible repeater station buffers. The slave presents data on risingedges of EMC, and the master latches data on the following rising clockedge. This allows a complete clock time for propagation of the clock tothe slave, slave clock-to-output delay, and return propagation time.

During a bus transaction, register fields are presented on the bus mostsignificant bit first. The P1 bit of the 2-bit parity field is presentedfirst, then the P0 bit. The master state machine actions are describedwith respect to both the rising and falling edges of EMC while the slaveis assumed to have no other time base than EMC and may operatecompletely on EMC rising edges. EMC is driven low when not in use, tominimize possibility of clocking false data into slaves.

Bus Transaction Sequence

The following paragraphs describe the various components of the EM bustransaction sequence, both when writing data to the slave and whenreading data from the slave. The following actions are assumed to begenerated from the master (the EM Unit) unless they are specificallyattributed to be performed by the slave. The following text and thesubsequent clocking diagram will assist in understanding the transactionsequence.

Sequence Start—An EM bus transaction is triggered by a software write tothe EM0START or EM1START register. The in-progress bit of the EM statusregister is set immediately. Further write accesses to EM registers aredisabled by the ASIC while the in-progress bit is set to avoiddisturbing the bus sequence in progress. It is the responsibility ofsoftware to ensure that new bus transactions are triggered only when theEM Unit is idle (in-progress bit is low). The bus transaction is clockedfrom the EMC0 signal, if the sequence was triggered by a write to theEM0START register. If the sequence was triggered by a write to theEM1START register, then the bus transaction is clocked from the EMC1signal. The actual start of the EM bus sequence (referred to as EMCST)occurs on the first falling edge of the EMC time base after thetransaction trigger.

Module/Register Address—At point EMCST, the master drives the XA_ODsignal low and enables the EMC and EMD signals. The detection of anactive XA_OD on a rising edge of EMC is used by the slave to identifythe start of an addressing operation. The master then produces 10 clockson the EMC signal, clocking the contents of the EMADDR register and 2parity bits, P1 and P0, in sequence on EMD. The first bit of EMADDRpresented on EMD is valid at the EMCST point. The XA_OD signal is drivenhigh again at EMC↓ 1. The master presents a new bit on EMD at each EMC↓.The EMD signal is released at EMC↓ 10. The slave latches validinformation at EMC↑ 1:10 (rising edge of EMC 1:10).

Read Data Sequence—For a read transaction, the EMDDIR signal is drivento the low state at EMC↓ 10. After the clocking of the module/registeraddress bits, the master produces 13 more clocks (11:23) on the EMCsignal. EMC clocks 11:12 are idle clocks to allow the slave time to makethe appropriate register data and parity available for transfer. Theselected slave provides 8 data and 2 parity bits on the EMD signal atEMC↑ 13:22 and returns to idle state at EMC↑ 23 (the slave releases theEMD signal at this time). The master latches information at EMC↑ 14:23.The slave provides the most significant bit of the data value first,then the P1 parity bit, and finally the P0 parity bit. The data value isstored in register EMDATA. The master determines the parity of the valuestored in EMDATA and compares this calculated parity against the paritybits received from the slave. If the calculated parity and receivedparity do not agree, then the error bit in the EM status register isset. Otherwise, the error bit is cleared. The EMDDIR signal is released(driven high) on EMC↓ 23.

Write Data Sequence—For a write transaction, after the clocking of themodule/register address bits, the master provides 14 more clocks (11:24)on EMC. The master provides the 8 data bits (from the EMDATA register)on EMD followed by the 2 parity bits (P1 then P0). The master presentsthe data and parity bits at EMC↓ 10:19, then releases the EMD signal anddrives the EMDDIR signal to the low state on EMC↓ 20. The slave latchesvalid information at EMC↑ 11:20. The slave responds to a complete writecycle and correct parity by clocking the bits 0 then 1 from EMD at EMC↑22:23. The master latches this acknowledge response on EMC↑ 23:24. Theslave returns to idle state and releases EMD at EMC↑ 24. If the 2-bitacknowledge value read by the master is not 01, then the error bit inthe EM status register is set. Otherwise, the acknowledge value iscorrect and the error bit is cleared. The EMDDIR signal is released(driven high) at EMC↓ 24.

Sequence End—The end of the bus sequence is defined to occur on thefirst rising edge of the EMC time base following EMC↓ 23 (readtransaction) or EMC↓ 24 (write transaction). At EMCND, the in-progressbit of the EM status register is cleared. The error bit must be validwhen the in-progress bit is cleared. The bus signals should be at theiridle states.

Parity Check Bits

Two parity bits are used to indicate the parity of a single 8-bit value.Each of is the 2 parity bits represents odd parity on 5 bits of thevalue, as shown in the table of FIG. 27. Odd parity on odd number ofbits ensures that fields of all 1's or all 0's have opposite polarityparity bits.

Software Interface Considerations

A typical EM bus transaction will include software writing the EMADDRregister, writing a data byte to the EMDATA register (if a writetransaction), then writing to the EM0START or EM1START registers toinitiate the sequence. The software will repeatedly read the in-progressbit of the EM status register to determine when the transaction iscomplete. On completion of the EM bus transaction, the in progress bitwill be cleared and the error bit will be set appropriately. The datavalue can now be read from the EMDATA register if a read transaction wasperformed. Software may ensure that only the EMSTAT register is readwhile the transaction is in progress and the EM Unit may be designed tocorrectly handle a read access of that register by the software at anytime.

If an interrupt event occurs while a EM bus transaction is in progressand the interrupting routine requires the use of the EM Unit, then thatroutine may sample the state of the in progress bit and wait for thetransaction to complete before accessing any other EM Unit registers.Such interrupt routines will have an obligation to save and restore thecontents of the EMADDR and EMDATA registers as well as the state of theerror bit. This is required so that those registers will contain thecorrect values for the bus transaction started by the interruptedroutine once control is returned back to that routine.

Output Disable Using the XA_OD Signal

The XA_OD signal serves the dual use of identifying the start of addresscycle and the occurrence of a output disable condition (caused by a CPUsystem fault). At the slowest expected bus rate of ˜1 MHz, the longestnormal assertion of XA_OD in address usage is ˜1 μs. A threshold of ˜100times this, or 100 μs for slave recognition of XA_OD as an outputdisable allows for a simple diode/R/C filter at the slave and gives anadequately responsive output disable function. The XA_OD external signalwill be the logical OR of the address cycle identification signal fromthe EM bus state machine and the outputs OK signal originating from theWatchdog Timer Unit.

User Program Memory

User program memory may be used to store the user program. The end ofthe main program may be terminated by the use of a MEND (main programend) instruction. The remaining portion of user program memory beyondthe MEND instruction may be reserved for subroutines, and interruptroutines.

Serial Communication

The PLC provides a serial communication port as described with referenceto FIG. 1. The communication port uses RS485 signal levels and iscapable of running at 9.6 KB, 19.2 KB or 187.5 KB, while supporting thesystem communication protocols (PPI or DP/T). This port serves as theprogrammer interface to the PLC. In addition the port is available inthe run mode for use as a general purpose communication port (referredto as freeport mode) under the complete control of the user program. Infree port mode the communication port is capable of operating at baudrates from 300 baud to 38.4 KB. The physical connection to the RS485port is provided by a nine pin D connector.

Special Memory (SM) bits (see section 6.2, SM2, SM3, SM30 and SM130) areprovided for free port use of the communications port. The default stateof the special memory bits that control the use of the communicationport enables the use of the communication port as a programmerinterface. If the user program turns on the special memory bit thatcontrols the communication port's use, the user program will be enabledto send and receive messages through the communication port. In thismode of operation the user can configure the port for any characterbased protocol desired (7 or 8 bits/character, odd, even or no parity,and baud rate). The port will operate in half duplex mode and the userprogram can operate the port in polled or interrupt mode. A receivecharacter buffer is provided in the SM user area, along with acommunication status register, and a configuration register, whichincludes the bit that controls the port's mode of operation. Allcommunication functions except transmitting can be performed through thespecial registers in SM memory. Transmitting can only be accomplishedusing the special write port message instruction. The user program neverhas direct access to the communications controller or the interruptstructure of the machine.

PPI Master and Slave Modes Network Read and Write

The PLC may function as a PPI Slave. In PPI Slave mode the PLC acts as aresponder to communication messages.

In one arrangement of the invention, when the CPU is placed in the Runmode, the PLC can function as a PPI Master as well as a PPI Slave. Theuser can select PPI Master mode under the control of the user programstored in user program memory. In this arrangement, a well-knowntoken-ring communication protocol may be implemented to effectcommunication between master and slave. In PPI Master mode the PLC iscapable of holding the token and initiating PPI requests therebyenabling the user to access data in other CPUs via the network read andwrite instructions. When the CPU is not holding the token, it respondsto all requests as a PPI slave. The communication buffer sizes for PPIcommunication are defined in the table shown in FIG. 28.

While the PLC is functioning as a PPI Master, it will maintain thenetwork in accord with well-known communication standards (such as thePROFIBUS definition provided by the EN 50170 European Standard). The PLCwill use the following algorithm for calculating the target tokenrotation time.TTTR=(8+HSA)(256)(1/BR)where

-   -   TTTR—is the target token rotation time    -   HSA—is the highest station address    -   BR—is the baud rate in bits per second

If upon receipt of the token, the target token rotation timer hasexpired, the PLC will immediately pass the token to the next tokenholder without sending any messages that may have been queued prior toreceipt of the token.

Freeport Link Provided in PPI Master Mode

The present invention provides free port operation of the communicationsport, hereinafter “freeport”, that allows the user to control the porteither manually or by operation of a user program. The procedure offreeport operation is shown in FIG. 30 a.

In the instant invention, the user implements freeport (step S3000) useby forcing an interrupt (step S3002) of the PLC according to theafore-described interrupt architecture. In this case, the user initiatesfreeport communication while operating the PLC in master mode byattaching an interrupt event that will pass control of thecommunications port to the user program (step S3004). This is performedwhile the system protocol holds the token (step S3006).

In response, the PLC passes control to the user program (step S3008).The PLC controls the UART settings (step S3010) in accordance with theSM bit definitions SMB30 and SMB130 shown in FIG. 30 b. In thatinstance, the mode bits of SMB30 and SMB130 definitions are set by thePLC to PPI master mode (step S3012).

Once control is passed from the system to the user's interrupt routine,the user program controls transmission and reception of messages usingthe freeport (step S3014). Once the user program has completed its task,the user program may pass control back to the system by the execution ofa special instruction that terminates freeport operation (step S3016).The instruction used to terminate freeport operation is described in thetable shown in FIG. 29. The system will then resume normal operation bypassing the token to the next station (step S3018). The system isresponsible for maintaining all aspects of the network just as if theuser program had never been given a time slice during the token holdtime of the PLC (step S3020).

Built In Freeport Protocol

In order to provide higher performance for communication using PPIprotocol, a built-in protocol selection option is provided for the PPIprotocol. When the PLC is placed in the RUN mode and the freeport PPIprotocol is selected by the value written to SM30 or SM130, thecommunication port will be configured according to the values writteninto SM30 or SM130. When freeport mode is exited, the PLC will revertback to the default PPI protocol at the selected baud rate. The code forselecting freeport PPI protocol will be as defined by SM30 (port 0) andby SM130 (port 1). The table in FIG. 30 b gives the definition of SM30and SM130.

Freeport Receive Message Interrupt

In order to simplify the programming for freeport communications, thePLC supports a receive message instruction that may be used inconjunction with a receive message event interrupt. The user specifiesthe conditions that are required to define the beginning and end of amessage. The PLC supports the following message conditionspecifications:

Port 0:

SMB86—Message Status Byte: Indicates termination conditions

SMB87—Message Control Byte: Enables the selected message receivecriteria

SMB88—Start Character: The character that uniquely identifies the startof a new message

SMB89—End Character: The character that uniquely identifies the end ofthe message

SMW90—Idle Line: Time period after which the first character receivedstarts a new message

SMW92—Inter-character/Message Time Out: The maximum time allowed betweencharacters or for the message to be received. Usage is determined by themessage control byte.

SMB94—Character Count: The maximum length of the receive message

Port 1:

SMB86—Message Status Byte: Indicates termination conditions

SMB87—Message Control Byte: Enables the selected message receivecriteria

SMB88—Start Character: The character that uniquely identifies the startof a new message

SMB89—End Character: The character that uniquely identifies the end ofthe message

SMW90—Idle Line: Time period after which the first character receivedstarts a new message

SMW92—Inter-character/Message Time Out: The maximum time allowed betweencharacters or for the message to be received. Usage is determined by themessage control byte.

SMB94—Character Count: The maximum length of the receive message

The first byte of the receive buffer is used as a character counterwhich may indicate how many characters were received by the receivemessage function. The definition of each of these special memoryregisters is given in the table shown in FIGS. 30 c and 30 d.

DP_S7 Communications

The PLC may support the DP/T protocol that provides a MPI transport forMaster-Slave communications. PPI messages are completely compatible withthe DP/T messages, so no special selection of protocol is required. ThePLC may accept either a PPI request or a DP/T request and respondaccordingly. Support for DP/T communications over the PPI port mayinclude being HD4 compliant on transmissions from the PLC at all baudrates supported.

While PPI is a connectionless protocol, DP/T is a connection orientedprotocol. The table of FIG. 30 d defines the number of DP/T connectionsand the buffer size for each connection supported by each PLC on eachport. This table does not include the buffer for the default SAP thatmay be supported on each port.

Modem Communications

The CPU of the present invention supports communications over standard10-bit, full duplex modems. This is considerably important because thenewer 11-bit modem in wide useage is often times too expensive. It wasdiscovered that this is particularly true in the industry setting whereindustrial technology typically lags behind the state-of-the-art incomputer hardware. On the other hand, the old 10-bit modems are plentyto be found on the industrial floor. This invention takes advantage ofthe discovery that there are a surplus of 10 bit modems in industry and,therefore, provides a unique 10-bit protocol that allows the PLC of thepresent invention (or any PLC or processor for that matter) to connectto factory floors so equipped. Of course, the 10-bit protocol of thepresent invention is valuable, and is applicable, to other settingswhere 10-bit modems are employed.

Another advantage of the 10-bit protocol of the present invention isthat the 10-bit protocol is compatible with higher order bit protocols.Thus, the 10-bit protocol may be received by an 11-bit modem or higher.

The 10-bit protocol of the present invention is counter to conventionalwisdom. Of course, it runs counter to intuition to employ lesser bitsthan is capable by the latest modem technology. It is even furthercontrary to conventional wisdom to employ the 10-bit modem protocolbecause the present invention sacrifices the parity bit, the linch-pinupon which all remote communications rely to ensure integrity of data.Indeed, when it is considered that PLCs are responsible for controllingmachinery, e.g., heavy equipment or precision robotics, it is realizedthat the company may be put out of business or, worse, someone isinjured by the improper commands of a PLC. The ordinary practitionerwould counsel strongly against a 10-bit protocol.

The 10-bit protocol of the present invention is described with referenceto FIG. 31. In one arrangement, the protocol used for modemcommunications is a modification of the standard PPI protocol. Ofcourse, other bit assignments are possible. The PPM or Point to PointModem protocol specified here assigns the following bits:

-   -   1—Start bit    -   8—Data bits    -   1—Stop bit    -   0—Parity bits

In the PPM protocol each request from the master receives a responsewithout an intervening acknowledgment or poll (step S3100). It isrecommended that only SD2 message types defined for PPI protocol areused in the PPM protocol (step S3104). In order to fulfill thisrequirement the master device may specify the use of the Master/Slaveprotocol (DP/T) in the establish association request (step S3106). Aftereach request, the master may allow, for example, 15 seconds for theslave device to respond before timing out the transaction (step S3108).Upon receipt of a request, the slave will allow a minimum turn aroundtime of, for example, 20 milliseconds before issuing the response (stepS3110).

Each request/response message is preferably a SD2 PPI message (stepS3112) with a sixteen bit CRC check code appended as the last two bytesof the message (step S3114). The CRC uses the industry standardpolynomial (X16+X12+X5+1) which is known as the CRC-CCITT polynomial(step S3116). The CRC is calculated over the entire SD2 frame excludingstart and stop bits (step S3118). The CRC generator may be preset to allones for both transmission and reception (step S3120). In this case,receipt of a valid message produces a pattern of 0×1D0F (step S3122).

The PPM protocol is signaled to the PLC by grounding pin 9 of thecommunication port connector. The PLC provides an internal pullupresistor on this pin in order to select standard PROFIBUS protocols.

It will be appreciated that the 10-bit modem protocol of the presentinvention is not necessarily limited to 10 bits and may be extended toany number of bit configurations including, for example, {1, 2, 3 . . .9, 10, 11 . . . ∞}. Indeed, the present invention may be betterconsidered an n-bit protocol that does not include a parity bit. Then-bit protocol may be implemented using the foregoing description toensure data integrity.

Hiding Portions of the User Program

The PLC of the present invention provides for the protection ofproprietary software or code. The same feature allows the PLC to hideportions of code from the user that may not be intended for the user'sviewing such as code generated by the PLC for performing routineoperations of the PLC. It will be appreciated that this functionencourages third party software developers to provide software who wouldotherwise shy away because the code is otherwise available to users.

To that end, the PLC supports a HIDE instruction that allows the user(or programming device) to identify and hide portions of the userprogram. The PLC programs are transferred and stored in the user programmemory with the hidden code sections encrypted. The PLC decrypts thehidden code sections at compile time for the purpose of generating theexecutable program. Once compilation has been completed, the hidden codesections are re-encrypted.

A user supplied password capability is provided that is used to encryptthe portion of the program that is to be hidden. In this way only theperson with authorization will be able to view the program sections thatare hidden.

As shown in FIG. 32 a, the hide instruction of the present inventionmarks the start of the encrypted portions. In the invention, a flag P isset to indicate that encrypted code exists. Now with reference to FIG.32 b, the operation of the hide function shall be described. In StepS3200, the user invokes the hide instruction for a particular piece ofproprietary code. In response, the PLC causes the P flag to be set (StepS3202). The PLC encrypts the code with a password that may be providedby the user (Step S3204) and inserts the hide label in the user memoryat the beginning and end of the code to ear-mark the encrypted portion(Step S3206). Upon compilation of the user program (Step S3208), the PLCcauses the encrypted portion to be decrypted (Step S3210) and the userprogram executes normally (Step S3212). Once execution of the program iscomplete, the PLC re-encrypts the proprietary code (Step S3214).

User Passwords

Restricted access to the PLC functions and memory may be providedthrough the use of a password which allows the user to configure accessrestrictions. Without a password the PLC may provide unrestrictedaccess. When the PLC is password protected, the PLC may prohibit alloperations that are restricted according to the configuration providedat the time the password was installed. The PLC may allow one station tolegitimize the communication link so that the user of that station canhave unrestricted access. The user who knows the password mayreconfigure the restrictions at any time by entering the correctpassword and editing the restriction class. Users who do not know thepassword must live with the restrictions assigned by the person whoknows the password.

In the event that the user forgets a password, the master password maybe used to gain access to the PLC. For the master password to work, thePLC mode switch may be in either the STOP or TERM position. When themaster password is used the following actions are taken by the PLCsoftware:

-   -   1. The PLC will transition to the STOP mode    -   2. The user program (OB1) is cleared (deleted)    -   3. The user data memory (DB1) is cleared (deleted)    -   4. If SDB0 exists, all parameters of SDB2 except the station        address and baud rate will be copied to SDB0    -   5. All SM flags are set to their default state    -   6. All flags are cleared    -   7. All SCR bits are cleared    -   8. Analog outputs will be frozen    -   9. All system data memory is set to the default state    -   10. All forced points are cleared and unforced    -   11. The time of day clock will not be changed    -   12. All timer/counter current data is cleared    -   13. The internal EEPROM is initialized (OB1 and DB1 are deleted        and SDB2 is copied to SDB0 with the exception of the station        address, and all inputs, outputs and data values are unforced)        System Function Call Support

The PLC 100 supports System Function Calls (SFCs) which allow the userto upload customized functions to the PLC.

In general, SFCs may be created, for example by the Siemens S7-200development groups, and downloaded to the PLC by the programming device.The PLC supports at least two SFCs. The maximum size of each SFC isdependent on the resources available in the specific PLC. For the CPUenvisioned in this invention the maximum size of each SFC is 8 KBincluding block header information. SFCs do not necessarily require anyuser data, although allocation of system data may be provided. SFCsdownloaded to the PLC become part of the operating system of that PLC.The PLC further allows the SFCs to be uploaded, downloaded, deleted andcopied to the memory cartridge. The PLC reports the existence of SFCs inthe appropriate directory communication functions.

The exemplary SFC instruction is shown in the table of FIG. 33 a. Now inmore detail, FIG. 33 b shows the method of the system function call. InStep S3300, the user alerts the PLC that an SFC download is desired. ThePLC performs the necessary handshaking protocol for the download (StepS3302) and the SFC is downloaded (Step S3304). The PLC stores thedownloaded function as part of the library of functions of the operatingsystem (Step S3306).

Load New Operating System

The PLCs may use FLASH EPROM for the operating system storage supportloading of a new operating system through the communication port. Thisis accomplished using a boot block in the FLASH EPROM that cannot beerased while installed in the PLC.

Loading of a new operating system can be accomplished by directlyconnecting a personal computer to the PLC using a PC/PPI cable. Use ofPROFIBUS cards installed in a personal computer or part of a PG are notpreferred because of the complexity of the PROFIBUS protocol which isthe only protocol that can be used with these devices.

The definition of the protocol used to load the new operating systemwill be identified by design and each communication message will providedata integrity checks in the form of checksums or CRC codes.Verification of integrity of the new operating system is before normaloperation is invoked, but after the FLASH EPROM has been programmed.

STL Status

It has been found that the conventional debugging system for debuggingprograms is flawed because the prior debugging system of the PLC debugsafter execution of the entire program or significantly interferes withthe timing of the program execution. To that end, the PLC supports theacquisition of the results of executing a group of instructions at theinstance each instruction in the group is executed. This novel featureis done in real time and while the PLC is executing the instruction. Inorder to implement this function, the PLC instruments the compiled codesegment for which status is to be gathered.

In one arrangement, the STL status is implemented on a display, such asprovided by a human-machine interface coupled to the PLC as well-known.The size of the status window on the display will be determined by thenumber of operand values that may be returned. The PLC may reserve, forexample, a 200 byte buffer for operand values. The size of this bufferis based upon the amount of data that can be returned in a singlecommunication frame.

Only one STL status window is preferably supported. Supporting multiplewindows requires additional RAM and it presents synchronization andtriggering problems. Of course, with future developments in memorytechnology, it is possible that multiple windows are a possibility.

Only one device should be able to open an STL status window. The STLstatus window function will be associated with the station address ofthe device which opened the STL status window. As long as the STL statuswindow remains open, all other requests for opening a STL status windowwill be rejected by the PLC

In order to open a STL status window the programming device may identifythe address of the first instruction in the window and then identify thenumber of instructions in the window. The basic format of the windowspecification is shown below.

Instruction Address of Window Start 2 Bytes No. of Instructions in STLStatus Window 2 Bytes

In this example, the only instruction address specified is the memoryaddress of the first instruction in the window. The programming devicebears the complete burden of making sure that the response datarequested in the setup of the STL status window fits in the 200 bytes ofthe response buffer.

It is a tenet that the STL status display must not cross the boundarybetween program parts, e.g., Main to Sub, Sub to Sub, Sub to Int, Int toInt. That would cause a disruption.

The exemplary format of the response buffer is shown in FIG. 34 a,wherein the instruction address of the start of the STL status window isreturned for positive confirmation that the PLC and the programmingdevice are viewing the same window. The length field indicates how manybytes of data values are contained in the data area for eachinstruction. Now the codes will be described:

V 0—data for this instruction is not valid because the instruction wasnot executed this scan.

1—data for this instruction is valid.

ENO The enable output bit that indicates if the instruction executedwithout error

SCR The bit value of the SCR stack.

S4–S0 S0 refers to the top of stack value and S1 refers to the next totop of stack value.

Data The STL status information returned for the instruction. Theprogramming device is responsible for parsing the data based upon therequest that set up the STL status window.

The PLC is responsible for making sure that the data captured in the STLstatus window comes from a single scan cycle. The PLC indicates this tothe programming device using the Valid flag (V) that is provided withpush down stack values for each instruction. Internally, the PLC trackswhat is valid by using a scan counter value that is reset by a requestfor the STL status buffer and which is incremented each scan. When avalue is to be written to the STL status buffer, the scan count statusword for the buffer is compared to the current value of the scancounter. If the values are different, the scan counter value will becopied to the scan count status word for the STL status buffer and all Vflags in the buffer will be cleared. Then the new values are stored inthe buffer and the V flag for that instruction will be set. If thevalues of the scan counts are the same, then the new values will bestored in the buffer and the V flag for that instruction will be set.This allows the buffer to always be updated with the data from the lastscan while keeping the data synchronized to the same scan.

Instrumenting the Compiled Code Window for STL Status

The apparatus and operation of the STL shall now be describedsimultaneously with reference to FIGS. 34 b and 34 c. The section ofcompiled code corresponding to the instructions in the STL Status Windowis identified by the PLC (Step S3400) (shaded in the figure). Theoriginal compiled code in this shaded region is saved (Step S3402) andthen restored once the STL Status operation is complete (S3420). Oncethe original compiled code has been saved, the instrumented code iscompiled in another section of RAM (S3404).

In order to discuss the process of instrumenting the code a few termsneed to be defined as follows:

-   -   Compiled instruction—A compiled instruction is the machine code        or executable code created by compiling a STL instruction.        Generally, each STL instruction is compiled into multiple        machine instructions.    -   Instrumented instruction—An instrumented instruction is a        compiled instruction along with the extra machine code required        to save the status of power flow and the operand values.

In order to preserve the addresses of labels, for-next loops,subroutines and interrupt routines, each compiled instruction in the STLStatus Window is replaced with a branch to the instrumented instruction(Step S3406). Each instrumented instruction is terminated with a returninstruction which transfers control to the next compiled instruction(Step S3408).

The branch to the instrumented code is made using an LCALL instruction(Step S3410). The LCALL transfers control to the instrumented code thatcaptures the STL status for that instruction (S3412). For those compiledinstructions which are longer than three bytes, the return value isadjusted so that control will be transferred to the next compiledinstruction (Step S3414).

The beginning address of the first compiled instruction in the STLStatus Window may be determined before instrumentation (S3416). In orderto reduce the amount of time required to determine this address, a tablecontaining a pointer to the address of, for example, every twenty-fifthcompiled instruction can be maintained (S3418). Such a table wouldrequire about 300 bytes for a 8192 byte user program. If more RAM isavailable, then the table of address pointers could point to every tenthcompiled instruction which would further reduce the time for STL statusinstrumentation.

The PLC utilizes the table of FIG. 34 c that lists the fastest Booleaninstructions and shows what changes are required to compile the code sothat all instructions are a minimum of three bytes in length. Theinstructions in the shaded portions of the table tells the PLC whichinstructions which may be modified.

The foregoing technique requires the least amount of RAM, but it alsorequires that all compiled code instructions take at least the number ofbytes required by the LCALL instruction that will be used to branch tothe instrumented code section. For purposes of clarity it is assumed inthe above that the LCALL instruction takes three bytes and that allcompiled instructions take three or more bytes.

Design Concept

The mechanical design concept for the PLC family is shown in FIG. 1. Thedesign concept is a “Brick” style that will have the ability to haveunits connected for expansion. These expansions units will also be ofthe same style and shape. The design goal is to make this unit as costeffective as possible while maintaining the same family appearance asthe Siemens S7-300™ and S7-400™. The PLC family will have the same colorand text style as the S7-300™ and S7-400™ family.

Housing

The PLC housing is molded in a uniform plastic and color (Noryl GFN1 SE1Anthrazit 614 Herst N.R. GE 93263). The unit is made up of a top, abase, two access covers, one DIN rail latch, and two sizes of lightpipes. All these parts snap together to allow for ease of manufacturing.Provisions in the housing is made to allow the PWB's to also snap intoposition. The I/O housing is designed in the same manner as the PLChousing. The housing will be designed for IP20 protection and to preventother objects (such as a coin) from entering the unit. The table in FIG.35 a shows one possible set of dimensions of the units

Unit Mounting

The PLC 3900 shown in FIG. 35 b is designed to be mounted either on aDIN rail 3906 or to be panel mounted 3908. A mounting latch will be usedto lock the unit onto a standard type 50022 DIN rail when the unit is tobe DIN rail mounted. When the unit is to be panel mounted, mountingholes are provided that accept either a metric M4 or a #8 type screwsize. The PLC 3904 is shown here in engagement with the I/O expansionmodule 3902. A clearance of, for example, 25 mm will be required aboveand below the unit to allow the user wiring access and to allow forproper cooling of the unit.

While the present invention has been described with reference tospecific values and circuit arrangements, it shall be appreciated thatother values and circuit arrangements may be substituted for thosedisclosed which is within the spirit and scope of the present invention.In addition, it will be appreciated that the practitioner will instantlyrecognize how to implement the software code of the PLC and for thatmatter will understand that the various software applications may bewritten in any suitable programming language as well as stored in anysuitable recording medium such as non-volatile memory include disc,CD-ROM or DVD, for example.

High Speed Discrete Output for Programming Logic Controller

Programmable logic controllers solve programmed logic equations usingstandard digital logic circuits operating as, for example, 5V or 3.3Vlow energy circuits. The results of these equations are logic signalsthat are then provided to direct current discrete output points thatcontrol significant energy (eg. 24VDC or greater voltage and currentsapproaching 1A or greater). These discrete output points may drive avariety of loads, including inductive and lamp loads that require robustdriver circuits. It is also desired by some users of programmablecontrollers to drive loads with rapid, precise switching to produce, forexample, counted pulse trains for stepper motors or pulse widthmodulated representations of precise analog values.

One method of meeting these needs is to provide output devices that arespecialized for high energy (eg. Optically isolated power transistors)and other output devices that are specialized for high speed and preciseswitching (eg. non-isolated switching transistors or 5V digital logicoutputs).

It would be an advantage if the same output design could be used forboth high energy applications and high speed/precise timingapplications, either at the same time or at different times, as might berequired by different users of the programmable logic controller. Itwould also be desired to maintain in that design optical isolation,which is very often employed in industrial controls for well knownadvantages. It would further be desired to realize the advantages of thecombined application while maintaining cost similar to prior designswith more limited application.

It would further be desired in such a design to limit power consumptionof the output circuit to minimize thermal rise of the programmable logiccontroller.

An additional desired feature for such discrete output circuits is thatthey have a means of suppressing voltage transients associated with turnoff of inductive loads. A further requirement of such discrete outputcircuits is that they withstand certain standard electromagnetic noiseimmunity tests without false turn ons or turn offs contrary to thecommanded logic state. A further requirement of such discrete outputcircuits is that they operate correctly and consistently over a widerange of supply voltage (for example, 20 to 30VDC). A furtherrequirement of such a circuit is that it be consistently reproducible inlow cost high volume serial production. A further requirement of such acircuit is that it default to a safe known state if the controllinglogic is not powered but the output circuit power is present.

A typical programmable controller discrete direct current output isshown in FIG. 3801 and employs an optical isolation transistor (3801) todrive the gate of a FET device (3802) through a suitable resistivenetwork (3803). The user supplied power supply (3804) and external load(3805) are isolated from the programmable controller logic. Additionalcomponents, such as properly placed capacitors, may be required to meetnoise immunity requirements.

An alternate implementation employed a bipolar transistor in place ofthe FET, with a different suitable resistive network to drive the base.Further alternate forms include current sinking type outputs instead ofthe current sourcing (high side driver) form shown, using acomplementary type FET or bipolar transistor.

This basic circuit topology provides a robust output, but cannot bereadily made to switch at speeds above a few kilohertz (or equivalently,with turn on/turn off delays below several microseconds to tens ofmicroseconds.) The major barrier to higher switching speed is theoptocoupler, particularly the turn off time. In order to provideguaranteed operation over a full user supply voltage range and with theoptocoupler gain variation associated with high volume low costproduction, as well as optocoupler gain variation with age, it isnecessary to design the optocoupler input drive circuit and theimpedance of the gate drive circuit at the optocoupler output so thatthe optocoupler is typically strongly saturated when the output stage isON. In order to keep power dissipation in the gate drive circuit atacceptable values, the gate drive circuit must be high impedance. With ahigh impedance output circuit, the optocoupler is very slow to turn offfrom saturation. Further, the high impedance of the drive circuitcontributes to slow switching of the power transistor by limiting therate of change of base or gate charge. All of these effects are furtheraggravated by any additional capacitance added into the circuit toincrease electromagnetic noise immunity.

Optocoupler devices are generally available on the market that cancouple a digital signal with switching rates far greater than are neededfor this application. These devices generally rely on switching anoptical transistor in a small signal linear range, then amplifying andconditioning the resulting output to achieve a logic level digitalsignal. Such devices are not readily suited to this application becausethey typically have one or more of the following drawbacks.

-   -   The device may require a low impedance supply of low voltage (5V        or 3.3V) power on the output side of the optocoupler for the        output amplifier/signal conditioner. Developing such a supply        voltage on the field side of the circuit requires additional        components and expense.    -   The device may not tolerate direct connection to the higher        voltage associated with the FET gate or bi-polar transistor base        circuit, thus requiring additional components to control the        gate or base.    -   The device may be significantly more costly than simple optical        transistors.

FIG. 39 shows the essential elements of the disclosed invention. Anexternal output load and output load supply voltage are connected asbefore to the PLC DC output circuit. Within the PLC, a negative voltageregulator (3901) provides a supply of gate drive voltage −Vg which isset to a suitable value more negative than the external supply voltage,eg. V+ −12V. An optical transistor (3902), when turned on, connects thegate of the output transistor (3904) to the supply voltage rail V+,turning the output transistor OFF. Another optical transistor (3903),when turned on, connects the gate of the output transistor (3904) to thesupply −Vg, turning the output ON and driving the external load. The PLClogic drives the optical transistors (3902) and (3903) as acomplementary pair, so that for the output OFF state (3902) isconducting and (3903) is not, and in the output ON state (3903) isconducting and (3902) is not. A relatively high impedance (eg. 10 KΩ)pull up resistor (3905) guarantees that the output is OFF in the casethat external load supply voltage is applied but PLC internals are notpowered.

On the transitions between output OFF and output ON, optical transistor(3903) turns on quickly, providing a path to discharge the FET gatecapacitance to −Vg and also providing the low impedance path requiredfor a quick turn off of (3902). Similarly, on the ON to OFF transition,(3902) quickly pulls the FET gate to V+ and provides a low impedancepath for the quick turn off of (3903). The drive circuit for the opticaltransistors employs a digital logic gate (3907) driving the opticaldiodes of each optocoupler through parallel RC networks (3905) and(3906). The resistor in each network (eg. 1 KΩ), provides a limited DCcurrent through the optical diode when the logic signal is in the properstate. The capacitor in each network (3905) and (3906) (eg. 100 nF)allows for a pulse of current through the associated optical diode whenthe digital logic signal switches to the proper state to turn that diodeon. The net effect is an initial strong turn on of the opticaltransistor, followed by a steady state minimal optical drive. Thiscorresponds, on the output side of the optocouplers, in an initial largeconduction of FET gate charge and base charge of the opposite opticaltransistor, followed by a steady state conduction that is onlysufficient to maintain the FET gate at the desired ON or OFF voltagelevel.

A resistor/capacitor network (3908) (eg. 10 KΩ, 1 μF) provides minimumload and decoupling of the negative voltage regulator. Capacitors (3909)(eg. 1000 pF) across the collector/emitter of the each opticaltransistor allows a path for noise coupled into the circuit via fieldwiring and the FET to by-pass the optical transistors without causingundesired switching of those devices.

A zener diode (eg. 36V) coupled with a reverse blocking diode (3910)provides inductive load clamping. As the FET (3904) attempts to turn offan inductive external load, inductive reaction will tend to drive theFET drain negative as the inductor attempts to maintain current. Thezener diode allows this negative voltage to be transmitted to the gatecircuit. The FET is maintained ON in a linear region, allowing currentto be maintained in the inductor without inducing a damaging voltage atthe FET drain. The linear operating region voltage drop of the FET,combined with any resistance in the load, eventually dissipates thestored inductor energy at which point the circuit completes turn off. Ablocking diode (3911) protects the circuit against damage by erroneousreverse polarity connections of the external load voltage supply.

With the foregoing invention, the afore-described problems are resolved.

1. A method comprising: regarding an entire user control program storedin a first section of memory and executed by a programmable logiccontroller, while said entire user control program is executing andwithout significantly interfering with execution timing of said entireuser control program, via a programmable logic controller operatingsystem program: displaying a section of said entire user control programindicated by a user to be debugged, said section having a beginningaddress of said section determined via a table of pointers toinstructions of said entire user control program, said section of saidentire user control comprising fewer instructions than said entire usercontrol program; compiling said section of said entire user controlprogram to be debugged in a second section of memory; without stoppingexecution of said entire user control program, automatically jumping tosaid second section of memory during real time execution of said entireuser control program when an instruction indicated to be debugged is tobe executed; and capturing a status of said instruction as it isexecuted.
 2. The method according to claim 1, further comprising: viasaid programmable logic controller operating system program, returningto first section of memory after said instruction indicated to bedebugged is executed.
 3. The method according to claim 2, furthercomprising: via said programmable logic controller operating systemprogram removing said section of said entire user control program fromsaid second section of memory once said status is captured.
 4. Themethod according to claim 1, further comprising; via said programmablelogic controller operating system program instrumenting each instructioncompiled in said second section of memory.
 5. The method according toclaim 1, further comprising via said programmable logic controlleroperating system program, storing a table relating instructions toboolean expressions, wherein said section of said entire user controlprogram is debugged with said boolean expressions.
 6. The methodaccording to claim 1, further comprising: via said programmable logiccontroller operating system program, providing a table of pointers toinstructions of said entire user control program, wherein saidinstructions are located in memory during debugging.
 7. The methodaccording to claim 1, further comprising: via said programmable logiccontroller operating system program, limiting a data size of eachcompiled instruction, wherein execution of said section of said entireuser control program to be debugged is faster and memory required tostore said section of said entire user control program is reduced. 8.The method of claim 1, further comprising: providing a table relatinginstructions to boolean expressions, wherein said section of said entireuser control program is debugged utilizing said boolean expressions. 9.The method of claim 1, further comprising: providing a table of pointersto instructions of said entire user control program.
 10. The method ofclaim 1, further comprising: providing a machine code instructionadapted to save a power flow status associated with said section of saidentire user control program.
 11. The method of claim 1, furthercomprising: providing a machine code instruction adapted to save anoperand value associated with said section of said entire user controlprogram.
 12. The method of claim 1, further comprising: comparing a scancount status word to a current value of a scan counter to determine thatsaid status came from a single scan cycle.
 13. The method of claim 1,further comprising: copying a scan counter value to a scan count statusword to determine that said status came from a single scan cycle. 14.The method of claim 1, further comprising: comparing a scan count statusword to a current value of a scan counter to determine that said statuscame from a single scan cycle; clearing a flag in a buffer if said scancount status word is different from said current value of said scancounter.
 15. The method of claim 1, further comprising: acquiringresults from an execution of said section of said entire user controlprogram.
 16. The method of claim 1, further comprising: executing saidsection of said entire user control program.
 17. The method of claim 1,further comprising: displaying results from an execution of said sectionof said entire user control program on a human machine interface of saidprogrammable logic controller.
 18. The method of claim 1, furthercomprising: determining a status window size by a number of operandvalues returned from an execution of said section of said entire usercontrol program, said status window adapted to display said status ofsaid instruction.
 19. A machine-readable medium having stored thereon aplurality of executable instructions, the plurality of instructionscomprising instructions for: regarding an entire user control programstored in a first section of memory and executed by a programmable logiccontroller, while said entire user control program is executing andwithout significantly interfering with execution timing of said entireuser control program, via a programmable logic controller operatingsystem program: displaying a section of said entire user control programindicated by a user to be debugged, said section having a beginningaddress of said section determined via a table of pointers toinstructions of said entire user control program, said sectioncomprising fewer instructions than said entire user control program;compiling said section of said entire user control program to bedebugged in a second section of memory; without stopping execution ofsaid entire user control program, automatically jumping to said secondsection of said memory during real time execution of said entire usercontrol program when an instruction indicated to be debugged is to beexecuted; and capturing a status of said instruction as it is executed.20. A circuit embodying a plurality of executable instructions, theplurality of instructions comprising instructions for: regarding anentire user control program stored in a first section of memory andexecuted by a programmable logic controller, while said entire usercontrol program is executing and without significantly interfering withexecution timing of said entire user control program, via a programmablelogic controller operating system program: displaying a section of saidentire user control program indicated by a user to be debugged, saidsection having a beginning address of said section determined via atable of pointers to instructions of said entire user control program,said section comprising fewer instructions than said entire user controlprogram; compiling said section of said entire user control program tobe debugged in a second section of memory; without stopping execution ofsaid entire user control program, automatically jumping to said secondsection of said memory during real time execution of said entire usercontrol program when an instruction indicated to be debugged is to beexecuted; and capturing a status of said instruction as it is executed.